package com.itheima.methodinference;

import com.itheima.methodinference.Student;

import java.util.Arrays;
import java.util.Comparator;

public class StaticMethodDemo {
    public static void main(String[] args) {
        //定义学生类
        Student[] stu = new Student[6];
        stu[0] = new Student("张三", 18, 100);
        stu[1] = new Student("李四", 19, 90);
        stu[2] = new Student("王五", 20, 80);
        stu[3] = new Student("赵六", 21, 70);
        stu[4] = new Student("孙七", 22, 60);
        stu[5] = new Student("钱八", 23, 50);
        for (int i = 0; i < stu.length; i++) {
            System.out.println(stu[i]);
        }
        System.out.println("------------------------------------------------------");

        //方法引用
        //Arrays.sort(stu, (o1. o2) -> Student.compareByAge(o1, o2));
        Arrays.sort(stu, Student::compareByAge);

        for (int i = 0; i < stu.length; i++) {
            System.out.println(stu[i]);
        }

    }
}
